package permutationAndCombination;


import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class Permutation {

    @Test
    public void testPermutation() {
        bt(3, 0, new ArrayList<>());
    }

    private void bt(int total, int begin, List<Integer> idxList) {
        if (begin == total) {
            System.out.println(idxList);
        } else {
            for (int i = 0; i < total; i++) {
                if (!idxList.contains(i)) {
                    idxList.add(i);
                    bt(total, begin + 1, idxList);
                    idxList.remove(idxList.size() - 1);
                }
            }
        }
    }
}
